#ifndef CPAGECTRL_H
#define CPAGECTRL_H

#include "CPageCtrl_global.h"


#include <QWidget>
#include <QDebug>
#include <QPushButton>
#include <QLineEdit>
#include <QHBoxLayout>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
#include <QLabel>

#include "../CLineEdit2/clineedit2.h"


QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

class CPAGECTRL_EXPORT CPageCtrl : public QWidget
{
    Q_OBJECT
public:
    //CPageCtrl();
    CPageCtrl(QWidget *parent = nullptr);
    ~CPageCtrl();

    void SetTotalCount(const int & nTotalPageCount, const int & nTotalItemCount, const int & nCurPageCount);
    int GetCurPageNum();
    void SetCurPageNum(const int & nCurpPageNum);
private slots:
    void OnBtnPreviousPageClicked();
    void OnBtnNextPageClicked();
    void OnLineEditTextChange(const QString &text);

    void OnBtnFirstPageClicked();
    void OnBtnLastPageClicked();
signals:
    void PageNumChange(const int & nPageNum);

private:
    void Init();

    void OnLineEditTextEnter();

private:
    QWidget *m_parent;

    QPushButton * m_btnPreviousPage;//上一页
    QPushButton * m_btnNextPage;//下一页
    CLineEdit2 * m_editCurPageNum;//当前页

    QPushButton * m_btnFirstPage;//第一页
    QPushButton * m_btnLastPage;//最后一页
    QLabel * m_pLabTotalPageCount;

    int m_nCurPageNum;
    int m_nTotalPageNum;
    int m_nTotalItemNum;

};

#endif // CPAGECTRL_H
